/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.almori.hr.timetracker;

import java.sql.SQLException;
import java.util.List;
import javax.faces.context.FacesContext;

/**
 *
 * @author Gcastillo
 */

public class DepartmentBean {
    private static TimeTrackerDAO dao = new TimeTrackerDAO();
    private Department department;
    private List<Department> departments;
    private String departmentId;
    private String departmentCode;
    private String departmentInitials;
    private String departmentName;

    public DepartmentBean() {
    }
    
    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    public List<Department> getDepartments() throws Exception {
        return departments;
    }

    public void setDepartments(List<Department> departments) {
        this.departments = departments;
    }

    public String getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(String departmentId) {
        this.departmentId = departmentId;
    }

    public String getDepartmentCode() {
        return departmentCode;
    }

    public void setDepartmentCode(String departmentCode) {
        this.departmentCode = departmentCode;
    }

    public String getDepartmentName() {
        return departmentName;
    }

    public void setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
    }
    
    public List<Department> findDepartments() throws SQLException, Exception{
        departments = dao.findDepartments(departmentCode, departmentInitials, departmentName);
        return departments;
    }
    
    public void reset(){
        departmentId = null;
        departmentCode = null;
        departmentInitials = null;
        departmentName = null;
        departments = null;
    }
    
    public void editDepartment(){
        String param = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id");
        Long id = Long.valueOf(param);
//        department.setId(Integer.parseInt(departmentId));
//        department.setDescription(departmentName);
    }

    public String getDepartmentInitials() {
        return departmentInitials;
    }

    public void setDepartmentInitials(String departmentInitials) {
        this.departmentInitials = departmentInitials;
    }
    
}
